package lzm.controller;


import lzm.entity.Student;
import lzm.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private IStudentService studentService;

    /**
     * 查询所有学生信息
     * @return
     */
    @RequestMapping("/queryAll")
    @ResponseBody
    public List<Student> queryAll() {
        return studentService.queryAll();
    }


    /**
     * 通过ID查询学生信息
     * @param id
     * @return
     */
    public Student queryById(Long id) {
        return studentService.queryById(id);
    }

    /**
     * 更新学生信息
     * @param student
     */
    @RequestMapping("/update")
    @ResponseBody
    public String update(Student student) {
        studentService.update(student);
        return null;
    }

    /**
     * 删除学生信息
     * @param id
     */
    @RequestMapping("/delete")
    @ResponseBody
    public void delete(Long id) {
        studentService.delete(id);
    }

    /**
     * 修改学生信息
     * @param student
     */
    @RequestMapping("/add")
    @ResponseBody
    public void add(Student student) {
        studentService.add(student);
    }

}